package com.vrsys.service;

import java.util.ArrayList;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.vrsys.domain.Comments;
import com.vrsys.persistence.CommentsMapper;
import com.vrsys.view.PageQuery;

@Service
public class CommentsService extends BaseService {
    @Autowired
    private CommentsMapper commentsMapper;

    public void pagingComments(PageQuery<Comments> pageQuery, int productId) throws Exception{
        List<Comments> comments = commentsMapper.getCommentsPage(productId,pageQuery.getFromIndex(),pageQuery.getElementNumber());
       if(null == comments)
           comments = new ArrayList<Comments>(0);

       pageQuery.setData(comments);
//       if(0 < pageQuery.getData().size())
//           pageQuery.setFromIndex(pageQuery.getFromIndex() + pageQuery.getElementNumber());
    }
}
